package com.qf.service.impl;

import com.qf.dao.MusicDao;
import com.qf.dao.MusicRespository;
import com.qf.pojo.Music;
import com.qf.service.MusicService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;
import java.util.Optional;

@Service
public class MusicServiceImpl implements MusicService {
    @Autowired
    MusicRespository musicRespository;
    @Autowired
    MusicDao musicDao;
    @Override
    public List<Music> findAll() {
        return musicRespository.findAll();
    }

    @Override
    public Music findById(Integer id) {
        Optional<Music> byId = musicRespository.findById(id);
        if(byId.isPresent()){
            return  byId.get();
        }
        return  null;
    }

    @Override
    public void deleteByid(Integer id) {
        musicRespository.deleteById(id);

    }

    @Override
    public void saveAndUpdateMusic(Music music) {
        musicRespository.saveAndFlush(music);
    }

    @Override
    public List<Music> findMusicByMname(String name) {
        List<Music> list = musicDao.findMusicByMname(name);
        return list;
    }

    @Override
    public List<Music> findMusicByMusicer(String auther) {
        return  musicDao.findMusicByMusicer(auther);
    }

    @Override
    public List<Music> findMusicByCla(String cla) {
        return musicDao.findMusicByCla(cla);
    }

    @Override
    public List<Music> findMusicByCStyle(String cstyle) {
        return musicDao.findMusicByCStyle(cstyle);
    }

    @Override
    public List<Music> findMusicByChangJing(String changjing) {
        return musicDao.findMusicByChangJing(changjing);
    }

    @Override
    public List<Music> findMusicByQingGan(String qinggan) {
        return musicDao.findMusicByQingGan(qinggan);
    }

    @Override
    public List<Music> findMusicByZhuTi(String zhuti) {
        return musicDao.findMusicByZhuTi(zhuti);
    }

    @Override
    public List<Music> findMusicByMName(String mname) {
        return musicDao.findMusicByMName(mname);
    }

    @Override
    public List<Music> findMusicByCdName(String cdname) {
        return musicDao.findMusicByCdName(cdname);
    }

    @Override
    public List<Music> findMusicByUid(Integer uid) {
        return musicDao.findMusicByUid(uid);
    }

}
